{% extends "base_generic.html" %}

{% block title %}Renew Book{% endblock %}

{% block content %}
    <h1>Renew: {{ book_instance.book.title }}</h1>
    <p>Borrower: {{ book_instance.borrower }}</p>
    <p {% if book_instance.is_overdue %}class="text-danger"{% endif %}>
        Due date: {{ book_instance.due_back }}
    </p>
    
    <div class="row">
        <div class="col-md-6">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">Renewal Form</h3>
                </div>
                <div class="panel-body">
                    <form action="" method="post">
                        {% csrf_token %}
                        
                        <div class="form-group">
                            <label for="{{ form.renewal_date.id_for_label }}">{{ form.renewal_date.label }}:</label>
                            {{ form.renewal_date }}
                            {% if form.renewal_date.help_text %}
                                <small class="form-text text-muted">{{ form.renewal_date.help_text }}</small>
                            {% endif %}
                            {% if form.renewal_date.errors %}
                                <div class="text-danger">{{ form.renewal_date.errors }}</div>
                            {% endif %}
                        </div>
                        
                        <div class="form-group">
                            <button type="submit" class="btn btn-primary">Renew Book</button>
                            <a href="{% url 'all-borrowed' %}" class="btn btn-default">Cancel</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
{% endblock %} 